package net.huashitong.Indicators.service;

import com.sirdc.modules.core.dao.BaseDao;
import com.sirdc.modules.sys.base.StringPKService;
import net.huashitong.Indicators.dao.BA02Dao;
import net.huashitong.Indicators.entity.BA02;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Service
public class BA02Service extends StringPKService<BA02>{


    @Autowired
    private BA02Dao dao;


    @Override
    protected BaseDao<BA02, String> getDao() {
        return dao;
    }

    @Override
    protected void beforeSave(BA02 obj) {
        obj.setSysId(dao.getSequence("seq_bab001"));
    }

    /*public void createOrUpdateDate(String bab201, String bab202,String bab203,String bab205) throws ParseException {
        String coursetime  = Until.getCurrentDate();
        *//*String years  =Until.getCurrenYear();
        years=years+"0601";
        SimpleDateFormat sdf  = new SimpleDateFormat("yyyymmdd");
        Date courseDate = sdf.parse(coursetime);
        Date tempyear  = sdf.parse(years);


        if(courseDate.compareTo(tempyear)>=0){

            years=Until.getCurrenYear()+"B";
        }else {
            years=Until.getCurrenYear()+"A";
        }
*//*

*//*
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        String years =Until.getHalfYear(coursetime);
        BA02 ab02s  = dao.queryDate(years);
        Date startDate =null,secondDate=null,overDate=null;

        startDate =sdf.parse(bab201);
        secondDate=sdf.parse(bab203);
        overDate=sdf.parse(bab202);

        if(ObjectUtils.isBlank(ab02s))
        {
            BA02 dates = new BA02();
            dates.setBAB201(bab201);
            dates.setBAB202(bab202);
            dates.setBAB203(bab203);
            dates.setBAB205(bab205);
            dates.setBAB205(years);
            this.save(dates);
            redisService.set("choosestatue","0");
            redisService.set("resultCode","0");
            redisService.set("startdate",bab201);
            redisService.set("seconddate",bab203);
            redisService.set("overdate",bab202);
        }
        else {
           // BA02 dates  = ab02;
            ab02s.setBAB201(bab201);
            ab02s.setBAB202(bab202);
            ab02s.setBAB203(bab203);
            ab02s.setBAB205(bab205);
           this.update(ab02s);
            redisService.set("choosestatue","0");
            redisService.set("resultCode","0");
            redisService.set("startdate",   bab201);
            redisService.set("seconddate",  bab203);
            redisService.set("overdate",    bab202);
        }
        overInfoDTO  = new OverInfoDTO();
        overInfoDTO.setBa02Service(this);
        overInfoDTO.setAb02Service(ab02Service);
        overInfoDTO.setMessage(bab202);
        overInfoDTO.setRedisService(redisService);
        overInfoDTO.setScheduleJobService(scheduleJobService);
        overInfoDTO.setScheJobService(scheJobService);
        overInfoDTO.setBa01Service(ba01Service);

        if(ObjectUtils.isBlank(startTimer))
        {
            startTimer  = new Timer();
            startTimer.schedule(new ItemJobService(redisService,bab201),startDate);
            secondTimer  = new Timer();
            secondTimer.schedule(new SecondProjectJobService(scheJobService,bab203,scheduleJobService),secondDate);
            overTimer = new Timer();
            overTimer.schedule(new OverCourseJobService(overInfoDTO),overDate );

        }else {

            try {
                startTimer.cancel();
                secondTimer.cancel();
                overTimer.cancel();
            }catch (Exception e)
            {
                System.out.println("已经取消了");
            }
            finally {
                startTimer=null;
                secondTimer=null;
                overTimer=null;
            }
            startTimer  = new Timer();
            startTimer.schedule(new ItemJobService(redisService, bab201),startDate);
            secondTimer  = new Timer();
            secondTimer.schedule(new SecondProjectJobService(scheJobService,bab203,scheduleJobService),secondDate);
            overTimer = new Timer();
            overTimer.schedule(new OverCourseJobService(overInfoDTO),overDate );

        }*//*


    }
*/
    public BA02 getDate(String bab205)
    {
        return dao.queryDate(bab205);
    }


}
